package com.nine.demo.properties;

import com.nine.demo.factory.SmsHandleFactory;
import com.nine.demo.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 消息发送的模板
 */
public class SmsTemplate {

    @Autowired
    private SmsProperties smsProperties;

    @Autowired
    private SmsHandleFactory smsHandleFactory;

    public void sendMsg(String phoneNumber, String templateCode, String templateParam) {
        // 获取云厂商的业务实现类
        String type = smsProperties.getType();
        SmsService smsService = smsHandleFactory.createSmsService(type);
        smsService.sendSms(phoneNumber, templateCode, templateParam);
    }

}
